/**
 * 
 */
package os.filesystem.tool;

import java.util.List;

import os.filesystem.file.Directory;
import os.filesystem.file.File.FileMeta;

/**
 *
 * Lists all the files in a folder.
 * 
 * @author Raghav Sidhanti
 * @since Mar 6, 2012 11:20:55 AM
 *
 */
public final class Ls extends FSTool{

	public static final String COMMAND_NAME = "ls";
	
	public void ls(Command command){
		List<FileMeta> fms = FSState.workingDir().getFileMetas();
		for(FileMeta fm:fms){
			String str = fm.getName();
			if(fm.getType().equals(Directory.TYPE)){
				str += "/";
			}
			System.out.print(str + "  ");
		}
		System.out.println("\n" + fms.size() + " file(s)");
	}
	
	@Override
	public void execute(Command command){
		ls(command);
	}
}
